<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<style type="text/css">
    .basic-table{border:0 none;border-collapse:collapse;width:100%;cellspacing:0;cellpadding:0}.basic-table th{background:none repeat scroll 0 0 #D9D9D9 !important;border-color:#D9D9D9 !important}.basic-table th,.basic-table td{background-color:#FFFFFF;border:1px solid #C5C5C5;color:#000000;padding:5px}.basic-table tbody tr td:first-child{font-weight:bold}
</style>
<table class="basic-table">
    <thead>
    <tr>
        <th style="width:100px"><strong>薪资扣款区间</strong></th>
        <th><strong>速扣值</strong></th>
        <th>备注</th>
    </tr>
    </thead>
    <tbody>
    <s:if test="#request.salaryIndividualTaxRules==null || #request.salaryIndividualTaxRules.size==0">
        <tr>
            <td colspan="3">无相关扣款规则</td>
        </tr>
    </s:if>
    <s:else>
        <s:iterator value="#request.salaryIndividualTaxRules" var="rule" status="sta">
            <tr>
                <td>${rule.amountStart}-${rule.amountEnd}</td>
                <td>${rule.fastCutValue}</td>
                <td>${rule.remark}</td>
            </tr>
        </s:iterator>
    </s:else>
    </tbody>
</table>
<div class="form-action clearfix" style="padding-top:20px">
    <p><a href="#salary/individual_tax_rule_main.xhtml" class="button"><span class="icon"
                                                                 style="background:url(${ctx}/images/img/add.png)">&nbsp;</span>管理</a>
    </p>
</div>

<table class="display" id="example">
    <thead>
    <tr>
        <th style="width:2%"><input type="checkbox" id="form-updates7"
                                    onchange="checkAll(this,'salary_Individual_Tax_${organizationId}')" value="1"/></th>
        <th style=" width:19%">自定义个人所得税名称</th>
        <th style=" width:19%">缴费基数</th>
        <th style=" width:12%">操作</th>
    </tr>
    </thead>
    <tbody>
    <s:if test="#request.salaryIndividualTaxes==null || #request.salaryIndividualTaxes.size==0">
        <tr class="gradeX">
            <td colspan="4">暂无方案数据</td>
        </tr>
    </s:if>
    <s:else>
        <s:iterator var="tax" value="#request.salaryIndividualTaxes" status="sta">
            <s:if test="#sta.even">
                <tr class="gradeX">
            </s:if>
            <s:else>
                <tr class="gradeC">
            </s:else>
            <td><input type="checkbox" name="salary_Individual_Tax_${organizationId}" value="${tax.id}"/></td>
            <td>${tax.title}</td>
            <td><span style="background:url(${ctx}/images/img/chart_bar_edit.png)"
                      class="icon">&nbsp;</span>${tax.linkedDataType.name}</td>
            <td class="gradeX"><a class="button"
                                  href="#salary/individual_tax_edit.xhtml?organizationId=${organizationId}&salaryIndividualTax.id=${tax.id}&t=<%=new java.util.Date().getTime()%>"><span
                    style="background:url(${ctx}/images/img/add.png)" class="icon">&nbsp;</span>修改</a></td>
            </tr>
        </s:iterator>
    </s:else>

    </tbody>
</table>

<p>
    <%@ include file="/WEB-INF/pages/common/main_orgtab_pager.jsp" %>
</p>

<div class="tabs side grid_12 leading">
    <div class="clear"></div>
    <div class="grid_12">
        <div class="form-action clearfix">
            <p>
                <a class="button"
                   href="#salary/individual_tax_edit.xhtml?organizationId=${organizationId}&t=<%=new java.util.Date().getTime()%>"><span
                        style="background:url(${ctx}/images/img/add.png)" class="icon">&nbsp;</span>添加方案</a>
                <a class="button" href="javascript:void(0)" onclick="deleteIndividualTaxcase();"><span
                        style="background:url(${ctx}/images/img/cancel.png)"
                        class="icon">&nbsp;</span>删除</a>
            </p>
        </div>
    </div>
</div>


<script type="text/javascript">
    //删除个税方案
    function deleteIndividualTaxcase() {
        var checkIds = new Array();
        $("input[type='checkbox'][name='salary_Individual_Tax_${organizationId}']").each(function() {
            if (this.checked) {
                checkIds.push(this.value);
            }
        });
        if (checkIds.length == 0) {
            alert("请选择要删除的项");
            return;
        }
        if (confirm("确定要删除选中的数据吗？删除后将无法恢复!")) {
            doDeleteTaxcases(checkIds.join(","))
        }
    }

    function doDeleteTaxcases(ids) {
        var url = "${ctx}/salary/individual_tax_remove.xhtml";
        $.ajax(url, {
            type: "POST",
            data:{"taxIds":ids},
            dataType:"html",
            cache:false,
            success:function(a) {
                return pageDownloaded(a, url);
            },
            complete:function() {

            }
        });

    }

</script>